const nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({
  // host : 'smtp.sina.com',
  service: 'QQ', // 使用了内置传输发送邮件 查看支持列表：https://nodemailer.com/smtp/well-known/
  port: 465, // SMTP 端口
  secureConnection: true,
  auth: {
    user: 'xxxxxxxxxx@qq.com',
    pass: 'xxxxxxxxxxxxx',
  }
});

let mailOptions = {
  from: '"注册工程师工程网" <1350781233@qq.com>', // sender address
  to: 'judyjim@163.com', // list of receivers
  subject: 'Hello', // Subject line
  // 发送text或者html格式
  // text: 'Hello world?', // plain text body
  html: '<b>Hello world?</b>' // html body
};

var send = function(){
  transporter.sendMail(mailOptions, (error, info) => {
    if (error) {return console.log(error);}
    console.log('Message sent: %s', info.messageId);
  });
}

module.exports.sendEmail = send;

